package com.example.dddsample.infrastructure.persistence.assembler.mapper;

import com.example.dddsample.domain.entity.CustomerAggregate;
import com.example.dddsample.infrastructure.persistence.po.CustomerPo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface CustomerAggregateMapper {

    CustomerAggregateMapper INSTANCE = Mappers.getMapper( CustomerAggregateMapper.class );

    @Mappings({
            @Mapping(target="custId",source="source.custId"),
            @Mapping(target="custName",source="source.custName"),
            @Mapping(target="province",source="source.addressVO.province"),
            @Mapping(target="city",source="source.addressVO.city"),
            @Mapping(target="address",source="source.addressVO.addressDetail")
    })
    CustomerPo fromCustomerAggregate(CustomerAggregate source);

    List<CustomerPo> fromCustomerAggregateList(List<CustomerAggregate> source);
}
